from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.
from base_model import BaseModel


class User(AbstractUser):

    deleted = (
        ('0', '是'),
        ('1', '否')
    )
    name = models.CharField(max_length=50, verbose_name='名字')
    phone = models.CharField(max_length=11, verbose_name='手机号')
    is_deleted = models.CharField(max_length=2, default='0', choices=deleted, verbose_name='是否删除')

    class Meta:
        db_table = 'user'
        verbose_name = '用户'
        verbose_name_plural = verbose_name


class Role(BaseModel):
    # 不允许删除角色
    Role_Sign = (
        ('0', '顾客'),
        ('1', '批发商'),
        ('2', '店员'),
        ('3', '老板')
    )
    sign = models.CharField(max_length=2, default='0', choices=Role_Sign, verbose_name='角色标识')
    user = models.ManyToManyField(User, related_name='role', verbose_name='用户')

    class Meta:
        db_table = 'role'
        verbose_name = '角色'
        verbose_name_plural = verbose_name
